#include <stdio.h>
#include <fcntl.h>

int main(void)
{
    FILE *fp;
    int fd = open("data.dat", O_WRONLY | O_CREAT | O_TRUNC);
    if(fd == -1) {
        fputs("文件打开错误", stdout);
        return -1;
    }
    fp = fdopen(fd, "w");
    fputs("网络编程 \n", fp);
    fclose(fp);
    return 0;
}